//package com.ellison.composemovie.ui
//
//import androidx.annotation.StringRes
//import androidx.compose.foundation.ExperimentalFoundationApi
//import androidx.compose.material.*
//import androidx.compose.material.icons.Icons
//import androidx.compose.material.icons.filled.*
//import androidx.compose.runtime.*
//import androidx.compose.ui.graphics.Color
//import androidx.compose.ui.graphics.vector.ImageVector
//import androidx.compose.ui.res.stringResource
//import androidx.compose.ui.tooling.preview.Preview
//import androidx.navigation.NavHost
//import com.song.composejoke.R
//
//@ExperimentalFoundationApi
//@Preview
//@Composable
//fun Navigation() {
////    val movieViewModel: MovieViewModel = viewModel()
////
////    val (title, setTitle) = remember { mutableStateOf(baseTitle) }
////    val (canPop, setCanPop) = remember { mutableStateOf(false) }
////
////    val navController = rememberNavController()
////    navController.addOnDestinationChangedListener { controller, _, _ ->
////        setCanPop(controller.previousBackStackEntry != null)
////    }
////
////    // Used for check if is movie detail screen.
////    val isCurrentMovieDetail = remember { mutableStateOf(false) }
////
////    // Used for get current tab icon to tool bar
////    val toolBarIcon = remember { mutableStateOf(Icons.Default.Search) }
////
////    Scaffold(
////        bottomBar = {
////            BottomNavigation {
////                val navBackStackEntry by navController.currentBackStackEntryAsState()
////                val currentRoute = navBackStackEntry?.arguments?.getString("KEY_ROUTE")//FIXME
////
////                items.forEach { screen ->
////                    BottomNavigationItem(
////                        icon = { Icon(screen.icon, screen.route) },
////                        label = { Text(stringResource(screen.resourceId)) },
////                        selected = currentRoute == screen.route,
////                        onClick = {
////                            navController.navigate(screen.route) {
////                                // Pop up to the start destination of the graph to
////                                // avoid building up a large stack of destinations
////                                // on the back stack as users select items
//////                                    popUpTo = navController.graph.startDestination //FIXME
////                                popUpTo = navController.graph.startDestinationId
////                                // Avoid multiple copies of the same destination when
////                                // reselecting the same item
////                                launchSingleTop = true
////
////                                toolBarIcon.value = screen.icon
////
////                                Utils.logDebug(
////                                    Utils.TAG_LAUNCH, "BottomNavigation Item click "
////                                            + "toolBarIcon:${toolBarIcon.value.name}"
////                                )
////                            }
////                        },
////                        selectedContentColor = Color.Blue,
////                        unselectedContentColor = Color.Gray
////                    )
////                }
////            }
////        }
////    ) {
////        NavHost(navController, startDestination = Screen.Find.route) {
////            composable(Screen.Find.route) {
////                FindScreen(navController, setTitle, movieViewModel)
////                isCurrentMovieDetail.value = false
////            }
////            composable(
////                route = Constants.ROUTE_DETAIL,
////                arguments = listOf(navArgument(Constants.ROUTE_DETAIL_KEY) {
////                    type = NavType.StringType
////                })
////            ) { backStackEntry ->
////                DetailScreen(
////                    backStackEntry.arguments?.getString(Constants.ROUTE_DETAIL_KEY)!!,
////                    setTitle,
////                    movieViewModel
////                )
////                Utils.logDebug(
////                    Utils.TAG_LAUNCH,
////                    "Navigate to MovieDetail movieDetail:${isCurrentMovieDetail.value}"
////                )
////                isCurrentMovieDetail.value = true
////            }
////            composable(Screen.Store.route) {
////                StoreScreen(setTitle)
////                isCurrentMovieDetail.value = false
////            }
////            composable(Screen.Favourite.route) {
////                FavouriteScreen(setTitle)
////                isCurrentMovieDetail.value = false
////            }
////            composable(Screen.Profile.route) {
////                ProfileScreen(setTitle)
////                isCurrentMovieDetail.value = false
////            }
////        }
////    }
//}
//
//@ExperimentalFoundationApi
//@Composable
//fun FindScreen(
//    navController: NavController,
//    setTitle: (String) -> Unit,
//    movieViewModel: MovieViewModel
//) {
//    setTitle(stringResource(id = R.string.screen_find))
//    Screen.Find(
//        movieViewModel,
//        onClick = { movie ->
//            setTitle("")
//            navController.navigate(Constants.ROUTE_DETAIL_PRE + movie.imdbID)
//        }
//    )
//}
//
//@Composable
//fun DetailScreen(
//    movieId: String,
//    setTitle: (String) -> Unit,
//    movieViewModel: MovieViewModel
//) {
//    val movies: State<List<Movie>> = movieViewModel.movies.observeAsState(emptyList())
//    movies.value.firstOrNull { it.imdbID == movieId }?.let {
//        setTitle(it.Title)
//        LaunchedEffect(it.imdbID) {
//            movieViewModel.getMovieComposeCoroutines(it.imdbID)
//        }
//        val moviePro: State<MoviePro> = movieViewModel.moviePro.observeAsState(MoviePro(it.Title))
//        Detail(moviePro.value)
//    }
//}
//
//@ExperimentalFoundationApi
//@Composable
//fun StoreScreen(
//    setTitle: (String) -> Unit
//) {
//    setTitle(stringResource(id = R.string.screen_store))
//    Store()
//}
//
//@ExperimentalFoundationApi
//@Composable
//fun FavouriteScreen(
//    setTitle: (String) -> Unit
//) {
//    setTitle(stringResource(id = R.string.screen_favourite))
//    // Favourite(testMoviePro, onClick = { /*TODO*/ })
//    Favourite(favouriteMovies, onClick = { /*TODO*/ })
//}
//
//@ExperimentalFoundationApi
//@Composable
//fun ProfileScreen(
//    setTitle: (String) -> Unit
//) {
//    setTitle(stringResource(id = R.string.screen_profile))
//    Profile(myAccount)
//}
//
//val items = listOf(
//    Screen.Find,
//    Screen.Store,
//    Screen.Favourite,
//    Screen.Profile
//)
//
//sealed class Screen(val route: String, val icon: ImageVector, @StringRes val resourceId: Int) {
//    object Find : Screen(Constants.ROUTE_FIND, Icons.Default.Search, R.string.tab_find)
//    object Store : Screen(Constants.ROUTE_STORE, Icons.Default.Store, R.string.tab_store)
//    object Favourite :
//        Screen(Constants.ROUTE_FAVOURITE, Icons.Default.Favorite, R.string.tab_favourite)
//
//    object Profile :
//        Screen(Constants.ROUTE_PROFILE, Icons.Default.AccountCircle, R.string.tab_profile)
//}